﻿// Decompiled with JetBrains decompiler
// Type: YJM_PTO.PublicZC
// Assembly: YJM_PTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 17EE8669-AD07-48C9-A340-87C7401F98C3
// Assembly location: C:\Users\Administrator\Desktop\bin\YJM_PTO.exe

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;


namespace YJM_PTO
{
  public class PublicZC
  {
    private static string[] sj = new string[5]
    {
      "OR HH 77 HZ",
      "33 OH 66 JZ",
      "99 OO 88 HZ",
      "77 UU 88 VZ",
      "33 O4 44 LZ"
    };
    private static Dictionary<string, string> dic = new Dictionary<string, string>()
    {
      {
        "A",
        "035"
      },
      {
        "B",
        "066"
      },
      {
        "C",
        "0tt"
      },
      {
        "D",
        "0H4"
      },
      {
        "E",
        "05A"
      },
      {
        "F",
        "0L3"
      },
      {
        "3",
        "0Mk"
      },
      {
        "5",
        "0Po"
      }
    };

    public static string Encrypt(string info)
    {
      string str = PublicZC.strToHexstr(info).Replace("5C 72 5C 6E", "0D 0A").Replace("3A", "AA").Replace("30", "O").Replace("32", "O2");
      foreach (KeyValuePair<string, string> keyValuePair in PublicZC.dic.OrderByDescending<KeyValuePair<string, string>, string>((Func<KeyValuePair<string, string>, string>) (o => o.Key)).ToDictionary<KeyValuePair<string, string>, string, string>((Func<KeyValuePair<string, string>, string>) (o => o.Key), (Func<KeyValuePair<string, string>, string>) (p => p.Value.ToString())))
        str = str.Replace(keyValuePair.Key, keyValuePair.Value);
      int index = new Random().Next(5);
      return PublicZC.sj[index] + " " + str;
    }

    public static string Decode(string info)
    {
      string[] strArray = info.Split('Z');
      foreach (KeyValuePair<string, string> keyValuePair in PublicZC.dic.OrderBy<KeyValuePair<string, string>, string>((Func<KeyValuePair<string, string>, string>) (o => o.Key)).ToDictionary<KeyValuePair<string, string>, string, string>((Func<KeyValuePair<string, string>, string>) (o => o.Key), (Func<KeyValuePair<string, string>, string>) (p => p.Value.ToString())))
        strArray[1] = strArray[1].Replace(keyValuePair.Value, keyValuePair.Key);
      strArray[1] = strArray[1].Replace("AA", "3A");
      strArray[1] = strArray[1].Replace("O2", "32");
      strArray[1] = strArray[1].Replace("O", "30");
      return PublicZC.hexStrToStr(strArray[1]);
    }

    private static string strToHexstr(string str)
    {
      char[] charArray = str.ToCharArray();
      string hexstr = "";
      byte[] numArray = new byte[str.Length];
      for (int index = 0; index < str.Length; ++index)
        numArray[index] = (byte) charArray[index];
      foreach (byte num in numArray)
        hexstr = hexstr + num.ToString("X2") + " ";
      return hexstr;
    }

    private static string hexStrToStr(string str)
    {
      str = str.Replace("\r", "");
      str = str.Replace("\n", "");
      string[] strArray1 = str.Split(' ');
      string str1 = "";
      foreach (string str2 in strArray1)
        str1 += str2;
      char[] charArray = str1.ToCharArray();
      string str3 = "";
      string[] strArray2 = new string[charArray.Length / 2];
      for (int index = 0; index < charArray.Length / 2; ++index)
      {
        char ch = (char) uint.Parse(charArray[2 * index].ToString() + charArray[2 * index + 1].ToString(), NumberStyles.AllowHexSpecifier);
        str3 += ch.ToString();
      }
      return str3;
    }
  }
}
